<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

class CoreBase extends CoreObject {
	var $_instances = array();
	var $_base;
	
	//constructor
	function CoreBase() {
		parent::CoreObject();
		$this->_base = new Base();
	}
	
	//methods
	function getInstance($class, $singleton = false, $file = '') {
		if( $singleton == false && isset($this->_instances[$class]) ) {
			return $this->_instances[$class];
		}
		$this->_base->loadclass($file);
		
		if( class_exists($class) ) {
			$obj = new $class();
			$obj->init();
			
			if( $singleton == false ) {
				$this->_instances[$class] = $obj;
			}
			
			return $obj;
		} else {
			$this->_base->error('Class ' . $classname);
		}
	}
}
//
?>